//
// Created by isabella on 25-5-24.
//
#include <common.h>

class Solution {
public:
    int majorityElement(vector<int>& nums) {
        unordered_map<int, int> map;
        int max_num = 0,max_cnt=0;
        for (auto x : nums) {
            map[x]++;
            int times = map[x];
            if (times > max_cnt) {
                max_cnt = times;
                max_num = x;
            }
        }
        return max_num;
    }
};